<template>
  <div class="box7">
    <div class="title">
      <p>年度游客量对比</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

//获取图表DOM实例
let charts = ref()

//组件挂载完毕
onMounted(() => {
  //初始化echarts实例
  let mycharts = echarts.init(charts.value)
  //设置echarts配置项
  mycharts.setOption({
    title: {
      text: '散点图',
      left: '40%',
      textStyle: {
        color: '#fff',
      },
    },
    xAxis: {
      type: 'category',
      show: true,
    },
    yAxis: {
      show: false,
    },
    grid: {
      //距离父容器上下左右的距离
      left: 20,
      right: 0,
      top: 20,
      bottom: 20,
    },
    series: {
      type: 'scatter',
      data: [33, 88, 21, 9, 78, 13, 31, 73, 22, 88, 31, 56, 31],
      //标记图形设置
      // symbol: 'diamond',
      // symbolSize: 10,
      //图文标签
      label: {
        // show: true,
        // position: 'top',
        // color: 'yellow',
      },
      itemStyle: {
        // color: {
        //   type: 'linear',
        //   x: 0,
        //   y: 0,
        //   x2: 1,
        //   y2: 1,
        //   colorStops: [
        //     { offset: 0, color: 'rgba(10, 10, 50, 1)' },  // 深蓝黑
        //     { offset: 1, color: 'rgba(0, 150, 255, 0.3)' } // 霓虹蓝
        //   ],
        //   global: false
        // }
      },
    },
  })
})
</script>

<style scoped lang="scss">
.box7 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin: 20px 0px;

  .title {
    p {
      color: #fff;
      font-size: 18px;
    }
  }

  .charts {
    height: calc(100% - 30px);
  }
}
</style>
